// import request from '@/utils/request'
import { fetch, fetchToken, fetchNoMsg, fetchForImg, fetchDownload } from '@/utils/fetch'
/* ============颜色管理-列表============*/
export function colourPageList(data) {
  return fetchNoMsg({
    url: '/base-color/pageList',
    method: 'get',
    params: data
  })
}
/* ============颜色管理-新增============*/
export function colourAdd(name) {
  const data = {
    name
  }
  return fetchNoMsg({
    url: '/base-color/create',
    method: 'post',
    data
  })
}
/* ============颜色管理-修改============*/
export function colourUpdate(id, name) {
  const data = {
    id,
    name
  }
  return fetchNoMsg({
    url: '/base-color/update',
    method: 'post',
    data
  })
}

/* ============品牌管理-列表============*/
export function brandPageList(data) {
  return fetchNoMsg({
    url: '/brand/list',
    method: 'get',
    params: data
  })
}
export function brandById(brandId) {
  return fetch({
    url: '/brand/getBrandById',
    method: 'get',
    params: { id: brandId }
  })
}

/* ============品牌管理-新增============*/
export function brandAdd(brandName) {
  const data = {
    brandName
  }
  return fetchNoMsg({
    url: '/brand/create',
    method: 'post',
    data
  })
}
/* ============品牌管理-修改============*/
export function brandUpdate(id, brandName) {
  const data = {
    id,
    brandName
  }
  return fetchNoMsg({
    url: '/brand/update',
    method: 'post',
    data
  })
}
/* ============型号规格-列表============*/
export function modelPageListById(brandId) {
  return fetchNoMsg({
    url: '/model/list',
    method: 'get',
    params: { brandId: brandId }
  })
}
/* ============型号规格-列表(无权限限制，用于商务政策，商品管理修改页面下拉)============*/
export function modelPageListNoAuth(brandId) {
  return fetchNoMsg({
    url: '/brand/listKeyValue',
    method: 'get',
    params: { id: brandId }
  })
}
export function modelPageListByOptions(data) {
  return fetch({
    url: '/model/list',
    method: 'get',
    params: data
  })
}
/* ============型号规格-新增或修改============*/
export function createOrUpdate(data) {
  return fetchToken({
    url: '/model/createOrUpdate',
    method: 'post',
    data
  })
}

/* ============商务政策-新增============*/
export function policyAdd(data) {
  return fetchToken({
    url: '/policy/create',
    method: 'post',
    data
  })
}
/* ============商务政策-修改============*/
export function policyUpdate(data) {
  return fetchNoMsg({
    url: '/policy/update',
    method: 'post',
    data
  })
}
/* ============商务政策-列表============*/
export function policyPageList(data) {
  return fetchNoMsg({
    url: '/policy/list',
    method: 'get',
    params: data
  })
}
/* ============商务政策-通过ID获得详情============*/
export function policyListById(policyId) {
  return fetchNoMsg({
    url: '/policy/get',
    method: 'get',
    params: { id: policyId }
  })
} 
/* ============商务政策-上传图片============*/
export function policyUpload(data) {
  // console.log(data.get('file'))
  return fetchForImg({
    url: '/file/upload',
    method: 'post',
    data
  })
}
/* ============商务政策-上传获取相对路径============*/
export function getRelativePath(data) {
  return fetchNoMsg({
    url: '/file/get_relative_path',
    method: 'get',
    params: data
  })
}
/* ============商务政策---汽车品牌/型号规格（去重）============*/
export function allPolicyBrandModel(data) {
  return fetchNoMsg({
    url: '/policy/listKeyValue',
    method: 'get',
    params: data
  })
}

/* ============商品管理-通过型号ID获得库存============*/
export function getStockByModelId(modelId) {
  return fetchNoMsg({
    url: '/good/get_stock_by_model_id',
    method: 'get',
    params: { modelId: modelId }
  })
}

/* ============经纪管理人-列表============*/
export function brokerList(data) {
  return fetchNoMsg({
    url: '/broker/list',
    method: 'get',
    params: data
  })
}
/* ============根据id获取经纪管理人-信息============*/
export function idList(data) {
  return fetchNoMsg({
    url: '/broker/getBrokerById',
    method: 'get',
    params: data
  })
}
/* ============经纪管理人-修改============*/
export function brokerUpdate(data) {
  return fetchToken({
    url: '/broker/update',
    method: 'post',
    data
  })
}
/* ============经纪管理人-新增============*/
export function brokerAdd(data) {
  return fetchToken({
    url: '/broker/create',
    method: 'post',
    data
  })
}
/* ============经纪管理人---汽车品牌============*/
export function allBrand(data) {
  return fetchNoMsg({
    url: '/brand/listKeyValue',
    method: 'get',
    params: data
  })
}
/* ============经纪管理人---经手销售============*/
export function getSaleUsers(data) {
  return fetchNoMsg({
    url: '/broker/getSaleUsers',
    method: 'get',
    params: data
  })
}
/* ============岗位列表============*/
export function roleList(data) {
  return fetchNoMsg({
    url: '/role/list',
    method: 'get',
    params: data
  })
}

/* ============获取所有权限============*/
export function resourceList(data) {
  return fetchNoMsg({
    url: '/resource/listAllResource',
    method: 'get',
    params: data
  })
}

/* ============岗位新增============*/
export function roleAdd(data) {
  return fetchToken({
    url: '/role/create',
    method: 'post',
    data
  })
}

/* ============获取岗位信息============*/
export function getDetail(id) {
  return fetchNoMsg({
    url: '/role/get_detail',
    method: 'get',
    params: id
  })
}

/* ============岗位修改============*/
export function roleUpdate(data) {
  return fetchToken({
    url: '/role/update',
    method: 'post',
    data
  })
}

/* ============获取所有通知============*/
export function allNotifications(data) {
  return fetchNoMsg({
    url: '/notification/list_all?dispatch_type=BROADCAST',
    method: 'get',
    params: data
  })
}

/* ============获取关联通知============*/
export function linked(id) {
  return fetchNoMsg({
    url: '/role/list_linked_notifications',
    method: 'get',
    params: id
  })
}

/* ============通知设置============*/
export function roleSetup(data) {
  return fetchNoMsg({
    url: '/role/notification/setup',
    method: 'post',
    data
  })
}

/* ============用户列表============*/
export function userList(data) {
  return fetchNoMsg({
    url: '/admin-user/list',
    method: 'get',
    params: data
  })
}

/* ============用户新增============*/
export function userAdd(data) {
  return fetchToken({
    url: '/admin-user/create',
    method: 'post',
    data
  })
}
/* ============获取用户信息============*/
export function userUpdate(id) {
  return fetchNoMsg({
    url: '/admin-user/getAdminUser',
    method: 'get',
    params: id
  })
}


/* ============修改用户============*/
export function editUpdate(data) {
  return fetchToken({
    url: '/admin-user/updateAdminUser',
    method: 'post',
    data
  })
}
/* ============用户获取所有岗位============*/
export function listRole(data) {
  return fetchNoMsg({
    url: '/admin-user/listRole',
    method: 'get',
    params: data
  })
}
/* ============商品列表============*/
export function goodList(data) {
  return fetchNoMsg({
    url: '/good/list',
    method: 'get',
    params: data
  })
}
/* ============商品新增============*/
export function goodAdd(data) {
  return fetchToken({
    url: '/good/add',
    method: 'post',
    data
  })
}
/* ============获取商品详情============*/
export function goodUpdate(id) {
  return fetchNoMsg({
    url: '/good/getGoodById',
    method: 'get',
    params: id
  })
}
/* ============修改商品============*/
export function goodEdit(data) {
  return fetchToken({
    url: '/good/update',
    method: 'post',
    data
  })
}
/* ============获取所有颜色============*/
export function colourRole(data) {
  return fetchNoMsg({
    url: '/base-color/list',
    method: 'get',
    params: data
  })
}
/* ============删除商品============*/
export function goodDelete (id) {
  return fetchToken({
      url: '/good/deleteGood',
      method: 'post',
      params: { id: id }
  })
}

/* ============商品---汽车品牌============*/
export function ownBrand(data) {
  return fetchNoMsg({
    url: '/brand/listKeyValue',
    method: 'get',
    params: data
  })
}
/* ============导出商品============*/
// export function goodExport(data) {
//   return fetchNoMsg({
//     url: '/good/exportList',
//     method: 'get',
//     params: data
//   })
// }
// 导出商品
export const goodExport = '/amdms/api/good/exportList'
/*export function goodExport(data) {
  return fetchDownload({
    url: '/good/exportList',
    method: 'get',
    params: { goodsPassel: data.goodsPassel, brandName: data.brandName, vinCode: data.vinCode, status: data.status }
  })
}
*/